<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=9" />
		<meta http-equiv="pragma" content="no-cache" />
		<title>新增内容</title>
		<%@ include file="../../../common/Admin-list.jsp"%>
		<!-- 配置文件 -->
	    <script type="text/javascript" src="<%=path %>/Scripts/UEditor/ueditor.config.js"></script>
	    <!-- 编辑器源码文件 -->
	    <script type="text/javascript" src="<%=path %>/Scripts/UEditor/ueditor.all.js"></script>		
		  
		<script type="text/javascript" src="<%=bpath %>Scripts/jquery/jquery.form.js"></script> 		 
		 
		<script type="text/javascript">	
		
		$(function(){
			var subUrl="../SiteContent/save.json";			
			if('${data.type}'!=null&&'${data.type}'=="editMenu"){ //修改 内容导航				
				$("#lblTitle").html('修改内容导航');			
				if('${data.siteMenu.issue}'=="0"){
					$("#issue").attr("checked",false);
				}					
				$("#menuName").val('${data.siteMenu.menuName}');	
				$("#typeID").val('${data.siteMenu.typeID}');				
				$("#icon").val('${data.siteMenu.icon}');
				$("#sortID").val('${data.siteMenu.sortID}');				
				$("#parentID").val('${data.siteMenu.parentID}');
				//内容
				$("#id").val('${data.siteContent.id}');											
				$("#tag").val('${data.siteContent.tag}');				
				$("#fk_menuId").val('${data.siteContent.fk_menuId}');								
				subUrl="../SiteContent/update.json?type=editMenu";				
			}else if('${data.type}'!=null&&'${data.type}'=="addMenu"){ //新增内容导航			
				$("#lblTitle").html('新增内容导航');
				subUrl="../SiteContent/save.json?type=addMenu";
			}else if('${data.type}'!=null&&'${data.type}'=="addSub"){ //新增二级 内容导航
				$("#lblTitle").html('新增二级内容导航');
				$("#parentID").val('${data.parentID}');								
				subUrl="../SiteContent/save.json?type=addMenu";				
			}else if('${data.type}'!=null&&'${data.type}'=="add"){ //新增模块
				$("#lblTitle").html('新增内容模块');
				$('#menuType,#menuSort').css('display','none');					
				$("#LabelName").html('模块名称');		
			}else if('${data.type}'!=null&&'${data.type}'=="edit"){ //编辑模块
				
				$("#lblTitle").html('编辑内容模块');
				$('#menuType,#menuSort').css('display','none');					
				$("#LabelName").html('模块名称');				
				
				if('${data.siteContent.issue}'=="0"){
					$("#issue").attr("checked",false);
				}
				$("#id").val('${data.siteContent.id}');											
				$("#tag").val('${data.siteContent.tag}');		
				$("#menuName").val('${data.siteContent.title}');
				$("#fk_menuId").val('${data.siteContent.fk_menuId}');
				subUrl="../SiteContent/update.json";
			}
					
			//保存
			$("#lnbSave").click(function(){								
				$("#addForm").ajaxSubmit({
					url:subUrl,
					type:"POST",
					beforeSubmit:checkForm,
					contentType:"application/x-www-form-urlencoded;charset=UTF-8",
					error:function(){},
					success:function(data){
						if(data.success==true){
							showTip("保存成功，返回列表页面！","succeed");					    	
						}else{
							//showTip("操作失败","warning");  
							art.dialog.alert('保存失败，请确认填写正确！');
						}
					},
				});
			});
		});
			
		function checkForm(){
			var flag=$('#addForm').form('validate');
			return true;
		}
				
		//消息提示  
		function showTip(mess,icon) {  
		    art.dialog({  
		        id : 'Tip',  
		        title : '消息',  
		        fixed : true,  
		        lock : true,  
		        opacity: .2,  
		        content : mess,  
		        icon : icon,  
		        time : 1  
		    });  
		    setTimeout('originReload()', 1000);  
		}  
		
		//重载来源页面  
		function originReload(){  
		    var win = art.dialog.open.origin;		    
		    win.location.reload();  
		}		
			
		</script>
		
</head>
<body>
<!---->
<div>
	<div id="tab">
        <ul>
            <li class="Current">
            	<a href="#" onfocus="this.blur()">
            		<span id="lblTitle" >  新增内容  </span>
            	</a>
            </li>
        </ul>
    </div>  
    <div id="menu">
        <ul>
            <li>
            	<a id="lnbSave">
            		<span><img src="<%=basePath %>pages/Admin/Images/Icon/save.gif" alt="Save" />保存</span>
            	</a>
            </li>
        </ul>
    </div>   
    
    <div id="middle"> 
    <form action="../SiteContent/save.json" id="addForm" name="addForm" method="post" >   
    <div class="editor">
        <table class="eTable">
            <tr class="eTr">
                <td class="name">         
                	 <label id="Label21" >是否显示</label>           
                </td>
                <td>	
                	 <input id="issue" type="checkbox" name="issue" checked="checked" value="1" />
                	 <label for="issue">网站显示</label>
				</td>
            </tr>
            <tr class="eTr" id="menuType">
                <td class="name">         
                	 <label id="Label2" >导航位置</label>           
                </td>
                <td>	
                    <select name="typeID" id="typeID" style="width:100px;">
						<option selected="selected" value="0">顶部导航</option>
						<option value="1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;底部导航</option>
					</select>               	
				</td>
            </tr>
            <tr class="eTr">
                <td class="name">
                    <label id="LabelName" >导航名称</label></td>
                <td>
                    <input id="menuName" name="menuName" class="input" ></input>
                    
                    <input id="id" name="id" type="hidden"></input>
                    <input id="parentID" name="parentID" type="hidden" value="0"></input>                    
                    <input id="categoryID" name="categoryID" type="hidden" value="1" ></input>
                    <input id="fk_menuId" name="fk_menuId" type="hidden" value="0" ></input>
                    
                </td>
            </tr>        
            <tr class="eTr">
                <td class="name">
                    <label id="Label4">内容标签</label></td>
                <td>
                    <input id="tag" name="tag" class="input"></input>
                    
                </td>
            </tr>
            <tr class="eTr" id="menuSort">
                <td class="name">
                    <label id="Label5" >导航排序</label></td>
                <td>
                    <input id="sortID" name="sortID" class="input" value="0"></input>
                </td>
            </tr>
            <!-- 百度编辑器  -->            
            <tr class="eTr">                
                <td colspan="2" >
                	<!-- 加载编辑器的容器 -->
				    <script id="container" name="contents" type="text/plain" style="width:1200px;height:240px;">
        				
    				</script>
                </td>
            </tr>
            
            
        </table>
        
    </div>
    </form> 
    </div>
    
        <!-- 实例化编辑器 -->
    <script type="text/javascript">
        var ue = UE.getEditor('container',{
        	autoClearinitialContent:true, //清除初始内容      
        	autoHeightEnabled: false,//是否自动长高，默认true
        	autoFloatEnabled:false, //是否保持toolbar的位置不动，默认true        	
        	topOffset :65        	//浮动时工具栏距离浏览器顶部的高度，用于某些具有固定头部的页面
        });        
              
       ue.ready(function() {
		    ue.setContent('${data.siteContent.contents}');
		});
		
    </script>
    
</div>
</body>
</html>